package blocks
{
	import org.flixel.FlxG;
	import entities.Player;
	import tools.SaveManager;
	
	public class Checkpoint extends DynamicBlock
	{
		
		public var _alreadyUsed:Boolean;
		
		public function Checkpoint(X:int, Y:int, infos:Object, mapName:String=null) {
			super(X,Y,infos, mapName);
		}
		
		override public function activate():void{
			super.activate();
			Registry.player.checkpoint = this;
			Registry.player.health = Registry.player.infos.gamePlay.health;
			switchTile(false);
			_alreadyUsed = true;
			active=false;
			SaveManager.saveGame('checkpoint');
		}
		
		override public function update():void{
			if( !_alreadyUsed && FlxG.keys.justPressed(Registry.gameInfos.controls.actionKey) ){
				activate();
			}
			active=false;
		}
		
		
	}
}